#include "test_crc.h"
#include "test_uart.h"







/** @defgroup test_crc8_result
  * @{ 
  */
int  test_crc8_result(void)
{
	uint8_t data;
	uint16_t rlt; 
	data = 0x12;
	CRC_init();
	rlt = CRC_CalcCRC8(data);
	return rlt;
}

/** @defgroup test_MultiCalccrc8_result
  * @{ 
  */
int test_MultiCalccrc8_result(void)
{
	volatile uint8_t count;
	volatile uint16_t rlt;

	uint8_t buffer2[64]; 
  buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	count = 4;
	CRC_init();
	rlt = CRC_MultiCalcCRC8(buffer2,count);	
	return rlt;
}


/** @defgroup test_crc8_flag
  * @{ 
  */
int  test_crc8_flag(void)
{
	uint8_t data;
	uint16_t rlt;
//	char buffer[5]; 
//	char buffer1[10]; 
	data = 0x12;
	CRC_init();
	rlt = CRC_CheckCRC8(data);

	return rlt;
}
/** @defgroup test_MultiCalccrc8_flag
  * @{ 
  */
int  test_MultiCalccrc8_flag(void)
{
	uint8_t count;
	uint16_t rlt;
	uint8_t buffer2[64]; 
  count = 4;
	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	
	CRC_init();
	rlt = CRC_MultiCheckCRC8(buffer2,count);

	return rlt;
}





/** @defgroup test_crc16_result
  * @{ 
  */
int  test_crc16_result(void)
{
	uint16_t data;
	uint16_t rlt;
	uint8_t buffer2[64]; 
	buffer2[0] = 0x12;
  buffer2[1] = 0x34;
	data = (buffer2[1]<<8)+ buffer2[0];
	
	CRC_init();
	rlt = CRC_CalcCRC16(data);

  return rlt;
}

/** @defgroup test_MultiCalccrc16_result
  * @{ 
  */
int  test_MultiCalccrc16_result(void)
{
	uint8_t count,i,j=0;
	uint16_t rlt;
	volatile char buffer[5]; 

	uint8_t buffer2[64]; 
	uint16_t buffer3[64];
	count = 4;
	
	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	
	for(i=0;i<count;i=i+2)
	  buffer3[j++] = (buffer2[i+1]<<8)| (buffer2[i]);
	CRC_init();
	rlt = CRC_MultiCalcCRC16(buffer3,count/2);

	
	return rlt;

}

/** @defgroup test_crc8_result
  * @{ 
  */
int  test_crc16_flag(void)
{
	uint16_t data;
	uint16_t rlt;
	volatile char buffer[5]; 
	volatile char buffer1[10]; 
  char buffer2[10];
	

	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	
	data = (buffer2[1]<<8)+ buffer2[0];
	CRC_init();
	rlt = CRC_CheckCRC16(data);

	return rlt;
}

/** @defgroup test_MultiCalccrc16_result
  * @{ 
  */
int  test_MultiCalccrc16_flag(void)
{
  uint8_t count,i,j=0;
	uint16_t rlt;
 
	uint8_t buffer2[64]; 
	uint16_t buffer3[64];
	
	count = 4;
	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	
	for(i=0;i<count;i=i+2)
	  buffer3[j++] = (buffer2[i+1]<<8)| (buffer2[i]);
	CRC_init();
	rlt = CRC_MultiCheckCRC16(buffer3,count/2);

	return rlt;
}




/** @defgroup test_crc8_result
  * @{ 
  */
int  test_crc32_result(void)
{
	uint32_t data;
	uint16_t rlt;
 
  uint8_t buffer2[64]; 
	
	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	
	data = (buffer2[3]<<24)| (buffer2[2]<<16)|(buffer2[1]<<8)|(buffer2[0]);
	CRC_init();
	rlt = CRC_CalcCRC32(data);

	
	return rlt;
}

/** @defgroup test_MultiCalccrc16_result
  * @{ 
  */
int  test_MultiCalccrc32_result(void)
{
	uint8_t count,i,j=0;
	uint16_t rlt;

	uint8_t buffer2[64]; 
	uint32_t buffer3[64];
	
	count = 4;
	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	
	for(i=0;i<count;i=i+4)
	  buffer3[j++] = (buffer2[i+3]<<24)| (buffer2[i+2]<<16)|(buffer2[i+1]<<8)|(buffer2[i]);
	CRC_init();
	rlt = CRC_MultiCalcCRC32(buffer3,count/4);

	
	return rlt;

}


/** @defgroup test_crc8_result
  * @{ 
  */
int  test_crc32_flag(void)
{
	uint32_t data;
	uint16_t rlt;
  uint8_t buffer2[64]; 
	

	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	
	data = (buffer2[3]<<24)| (buffer2[2]<<16)|(buffer2[1]<<8)|(buffer2[0]);
	CRC_init();
	rlt = CRC_CheckCRC32(data);
	

	return rlt;
}


/** @defgroup test_MultiCalccrc16_result
  * @{ 
  */
int  test_MultiCalccrc32_flag(void)
{
	uint8_t count,i,j=0;
	uint16_t rlt;
	uint8_t buffer2[64]; 
	uint32_t buffer3[64];
	
	count = 4;
	buffer2[0] = 0x12;
	buffer2[1] = 0x34;
	buffer2[2] = 0x56;
	buffer2[3] = 0x78;
	for(i=0;i<count;i=i+4)
	  buffer3[j++] = (buffer2[i+3]<<24)| (buffer2[i+2]<<16)|(buffer2[i+1]<<8)|(buffer2[i]);
	CRC_init();
	rlt = CRC_MultiCheckCRC32(buffer3,count/4);

	return rlt;
}

